$(document).ready(function(){
	$('.gallery').removeClass('gallery').addClass('galleria'); // adds new class name to maintain degradability
	
	$('ul.galleria').galleria({
		clickNext : false, // helper for making the image clickable. Let's not have that in this example.
		insert    : '#main_image', // the containing selector for our main image. 
		// If not found or undefined (like here), galleria will create a container 
		// before the ul with the class .galleria_container (see CSS)
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
            if (thumb.hasClass('selected'))
                return;
			
			// fetch the thumbnail container
			thumb.parents('li').siblings().children('img.selected').fadeTo('fast',0.3).removeClass('selected');
			
			// fade in active thumbnail
			thumb.addClass('selected');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
            thumb.css({display:'none', opacity:thumb.hasClass('selected')?1:0.3}).fadeIn('slow');
			
			// hover effects
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { if (!thumb.hasClass('selected')) thumb.fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
	});
});